<template>
  <div class="arrearPage-wrapper">
    <!-- <header class="flex">
          <div class="person-info">
            <div class="avarat">
              <el-avatar v-if="customerSex === '男'" size="small" :src="male"></el-avatar>
              <el-avatar v-if=" customerSex === '女'" size="small" :src="female"></el-avatar>
            </div>
            <span class="name">{{customerName || 'hh'}}</span>
          </div>
          <div class="info">
            <div>
              <span class="infos-label">病历号：</span>
              <span>{{customerHistorySickNum || '暂无'}}</span>
            </div>
            <div>
              <span class="infos-label">手机：</span>
              <span>{{customerPhone || '暂无'}}</span>
            </div>
          </div>
          <div class="info">
            <div>
              <span class="infos-label">就诊类型: </span>
              <span>11111111</span>
            </div>
            <div>
              <span class="infos-label">预约项目: </span>
              <span>11111111</span>
            </div>
          </div>
    </header> -->
    <div class="dialog-content">
      <!-- 项目 -->
      <div class="project" v-if="arrearsTitle === '收费'">
        <el-table
            :data="addProjectList"
            style="width: 100%"
            :header-cell-style="{background:'#fff', color:'#000'}"
            >
            <el-table-column
              v-for="(item) in MockColumns"
              :key="item.name"
              :prop="item.name"
              :label="item.lable"
              :width="item.name === 'toothBit' ? '120' : ''"
              align="center"
              >
              <template #default="scope">
                <div v-if="item.name === 'toothBit'" >
                  <div style="">
                    <ztooth 
                      :lTToolist="scope.row[item.name].leftTop" 
                      :rTToolist="scope.row[item.name].rightTop" 
                      :lBToolist="scope.row[item.name].leftBottom" 
                      :rBToolist="scope.row[item.name].rightBottom"
                      @getLeftData="(() => getLeftData(scope.$index))()"
                      @getRightData="(() => getRightData(scope.$index))()"
                      @getLeftBottomData="(() => getLeftBottomData(scope.$index))()"
                      @getRightBottomData="(() =>getRightBottomData(scope.$index))()"
                      ></ztooth>
                  </div>
                </div>
                <template v-else-if="item.name === 'doctorId'">
                  {{getName(optionsDoctors, scope.row[item.name])}}
                </template>
                <template v-else-if="item.name === 'nurseId'">
                  {{getName(optionsNurse, scope.row[item.name])}}
                </template>
                <template v-else-if="item.name === 'consultantId'">
                    {{getName(secondaryUserOptions, scope.row[item.name])}}
                </template>
                <div v-else>{{scope.row[item.name]}}</div>
              </template>
            </el-table-column>
        </el-table>
        <div class="charge-r-total">
          <span>总计金额: {{ orderDetailSumMoneyShow || '00.00'}}</span>
          <span>应付金额: {{ originalPriceShow || '00.00'}}</span>
        </div>
      </div>
      <!-- 支付方式 -->
      <div class="Payment-method">
        <div class="advance">
          <div class="advance-content">
              <div class="group" v-for="(item, index) in payment" :key="index">
                <div class="group-left">
                  <div class="label">支付方式: </div>
                  <el-select class="select-3 machin-select" v-model="item.payType"  placeholder="请选择">
                    <el-option
                      v-for="item in paymentOptions"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                      :disabled="item.disabled"
                      >
                    </el-option>
                  </el-select>
                  <div class="label">实付金额: </div>
                  <el-input class="input-5" v-model="item.moneyShow">
                      <template #prepend>￥</template>
                    </el-input>
                </div>
                <div class="group-right">
                  <el-icon v-if="item.isAdd" @click="addPayment"><plus /></el-icon>
                  <el-icon v-else @click="delPayment(index)"><minus /></el-icon>
                </div>
              </div>
          </div>
        </div>
      </div>
      <!-- 历史欠费 -->
      <div class="history-project">
        <div class="arrears-content">
            <el-table
                :data="arrearsData"
                style="width: 100%"
                @selection-change="handleSelectionChange"
                default-expand-all
                >
                  <el-table-column
                    type="selection"
                    width="55">
                  </el-table-column>
                  <el-table-column type="expand">
                        <template #default="props">
                          <!-- 支付方式 -->
                          <div class="Payment-method">
                            <div class="advance" style="border: 0">
                              <div class="advance-content" >
                                  <div class="group" v-for="(item, index) in props.row.payment" :key="Number(index)">
                                    <div class="group-left">
                                      <div class="label">支付方式: </div>
                                      <el-select class="select-3 machin-select" v-model="item.payType"  placeholder="请选择">
                                        <el-option
                                          v-for="item in paymentOptions"
                                          :key="item.id"
                                          :label="item.name"
                                          :value="item.id"
                                          :disabled="item.disabled"
                                          >
                                        </el-option>
                                      </el-select>
                                      <div class="label">实付金额: </div>
                                      <el-input class="input-5" 
                                        v-model="item.moneyShow" 
                                        @change="handleChangeInputVal($event, props.row)"
                                      >
                                          <template #prepend>￥</template>
                                        </el-input>
                                    </div>
                                    <div class="group-right">
                                      <el-icon v-if="item.isAdd"  @click="addPaymentItemList(props.row.payment)"><plus /></el-icon>
                                      <el-icon v-else @click="delPaymentItemList(props.row.payment, Number(index))"><minus /></el-icon>
                                      
                                    </div>
                                  </div>
                              </div>
                            </div>
                          </div>
                        </template>
                      </el-table-column>
                  <el-table-column 
                    show-overflow-tooltip
                    v-for="(item) in arrearsColumns"
                      :key="item.name"
                      :prop="item.name"
                      :label="item.viewName"
                      :width="item.columnWidth ? item.columnWidth : 'auto'"
                      align="center"
                  >
                        <template #default="scope">
                          <div>{{scope.row[item.name]}}</div>
                        </template>
                    </el-table-column>
              </el-table>
        </div>
        <header class="arrears-head">
          <span class="total">总欠费: </span>
          <span>{{totalArrears}}</span>
        </header>
      </div>
      
      <!-- 备注 -->
      <div class="info-footer">
        <div class="owe">
          <header class="owe-head">
            <div class="head-l">
              <span>欠费: </span>
              <span>{{allArrearsCopy || 0}}</span>
            </div>
            <div class="head-r">
                  <span>馈赠金: </span>
                  <span>{{ giftsOfGoldShow || 0}}</span>
                </div>
            <div class="head-r">
              <span>账户余额: </span>
              <span>{{accountBalance || 0}}</span>
            </div>
            <div class="head-r">
              <span>实付总额: </span>
              <span>{{paid + paidArrearageList}}</span>
            </div>
            <span></span>
          </header>
          
          <el-row align="middle" >
                <el-col :span="3" style="padding-left: 20px">付款时间</el-col>
                <el-col :span="8">
                  <el-date-picker
                    v-model="payTime"
                    type="datetime"
                    value-format="YYYY-MM-DD HH:mm:ss"
                    placeholder="请选择时间"
                  />
                </el-col>
          </el-row>
          <div class="owe-conntent">
              <span>备注</span>
              <el-input type="textarea" class="input-1" v-model="remark"></el-input>
          </div>
        </div>
      </div>
      
    </div>
  </div>

  <!-- 打印 -->
  <printHtml class="none" id="print-js" :printList='printList'></printHtml>
</template>

<script lang="ts">
import { Plus, Minus } from '@element-plus/icons-vue'
import { defineComponent, ref, reactive, watch, toRefs, computed } from '@vue/runtime-core';
import useRequet, { RespData } from "../../../../hook/network"
import usePromiseRequest from "../../../../hook/request"
import {OptionDisable, MockType, Doctors, ArrearsOrderPay} from "../../../../types"
import { getName } from "../../../../usefn/getName"
import ztooth from "../../../../components/tooch/imgTooth.vue"

import { getNowDate } from "../../../../utils/nowDate"
import { getOrderInfoAndDetailApi } from "../../../../api/refund"

import { getDoctorListAllAPi, getNurseListAllAPi, getConsultListAllAPi, getCustomerAccountApi } from "../../../../api/common"

import { ElMessage } from 'element-plus'
// 引入图片资源
import male from "../../../../assets/image/male-adult.png"
import female from "../../../../assets/image/female-adult.png"
import request from '../../../../hook/request';

import printHtml from '@components/printHtml/printHtml.vue'
import printJS from 'print-js'
import { nextTick } from 'vue';

type PayMoneys = {
  orderId: number,
  details: Details[]
}
type Details = {
  isAdd: boolean,
  payType: string,
  moneyShow: string | number
}
export default defineComponent({
  name: 'ArrearPage',
  props: {
    personID: {
      type: Number
    },
    orderId: {
      type: Number
    }
  },
  components: {
    ztooth,
    printHtml,

    Plus, Minus
  },
  emits: ['refeshList'],
  setup(props, ctx) {
    let ID = props.personID;
    // 账户余额
    let accountBalance = ref<string | number>(0);
    let giftsOfGoldShow = ref<string | number>(0);
    watch(() => props.personID, (newID) => {
      ID = newID;
      getCustomerAccountInfo(newID)
    })
    let OrderID = props.orderId
    console.log(OrderID)
    watch(() => props.orderId, (newID) => {
      newOrderId.value = newID
    })

    const request = useRequet({ path: "" });
    const list  = reactive({
      // 收欠费数据
      arrearsData: <any>[],
      arrearsColumns:[
        {
           id: 529,
            name: "createTime",
            viewName: "创建时间",
            type: 208,
            groupId: 501,
            dataSource: "",
            hint: null,
            defaultValue: null,
            length: null,
            minValue: null,
            maxValue: null,
            rangx: null,
            must: 1,
            errorHit: "",
            value: "",
            orderNum: 1,
            show: 1,
            canUpdate: 0,
            companyId: 1,
            listView: 1,
            insertShow: 1,
            canShow: 1,
            fixed: null,
            idName: null,
            columnWidth:'200',
        },
        {
           id: 529,
            name: "masterUserName",
            viewName: "医生",
            type: 208,
            groupId: 501,
            dataSource: "",
            hint: null,
            defaultValue: null,
            length: null,
            minValue: null,
            maxValue: null,
            rangx: null,
            must: 1,
            errorHit: "",
            value: "",
            orderNum: 1,
            show: 1,
            canUpdate: 0,
            companyId: 1,
            listView: 1,
            insertShow: 1,
            canShow: 1,
            fixed: null,
            idName: null,
            columnWidth:'100',
        },
        {
           id: 529,
            name: "originalPriceShow",
            viewName: "应收",
            type: 208,
            groupId: 501,
            dataSource: "",
            hint: null,
            defaultValue: null,
            length: null,
            minValue: null,
            maxValue: null,
            rangx: null,
            must: 1,
            errorHit: "",
            value: "",
            orderNum: 1,
            show: 1,
            canUpdate: 0,
            companyId: 1,
            listView: 1,
            insertShow: 1,
            canShow: 1,
            fixed: null,
            idName: null,
            columnWidth:'',
        },
        {
           id: 529,
            name: "amountMoneyShow",
            viewName: "实收",
            type: 208,
            groupId: 501,
            dataSource: "",
            hint: null,
            defaultValue: null,
            length: null,
            minValue: null,
            maxValue: null,
            rangx: null,
            must: 1,
            errorHit: "",
            value: "",
            orderNum: 1,
            show: 1,
            canUpdate: 0,
            companyId: 1,
            listView: 1,
            insertShow: 1,
            canShow: 1,
            fixed: null,
            idName: null,
            columnWidth:'',
        },
        {
           id: 529,
            name: "arrears",
            viewName: "欠款",
            type: 208,
            groupId: 501,
            dataSource: "",
            hint: null,
            defaultValue: null,
            length: null,
            minValue: null,
            maxValue: null,
            rangx: null,
            must: 1,
            errorHit: "",
            value: "",
            orderNum: 1,
            show: 1,
            canUpdate: 0,
            companyId: 1,
            listView: 1,
            insertShow: 1,
            canShow: 1,
            fixed: null,
            idName: null,
            columnWidth:'',
        },
        {
           id: 529,
            name: "remark",
            viewName: "备注",
            type: 208,
            groupId: 501,
            dataSource: "",
            hint: null,
            defaultValue: null,
            length: null,
            minValue: null,
            maxValue: null,
            rangx: null,
            must: 1,
            errorHit: "",
            value: "",
            orderNum: 1,
            show: 1,
            canUpdate: 0,
            companyId: 1,
            listView: 1,
            insertShow: 1,
            canShow: 1,
            fixed: null,
            idName: null,
            columnWidth:'',
        }
      ],
      // 收欠费支付方式
      payment:[
        {
          isAdd: true, // 是否显示添加
          payType: '微信', // 支付方式
          moneyShow: '' // 实付金额
        }
      ],
      arrearsList: <ArrearsOrderPay[]>[],
      payMoneys: <PayMoneys[]>[],

      payTime: getNowDate(),
      remark:'',
      loading: false
    })

    // 设置第一个支付方式 初始金额金额
    const setPamentMoney = (money: any) => {
      list.payment[0].moneyShow = money
    }
    const arrearsTitle = ref('收费')
     // 新增表格结构
    const MockColumns = [
      {
        name: 'toothBit',
        lable: '牙位'
      },
      {
        name: 'itemName',
        lable: '项目名称'
      },
      // {
      //   name: 'projectCode',
      //   lable: '项目编码'
      // },
      {
        name: 'unit',
        lable: '单位'
      },
      {
        name: 'priceShow',
        lable: '单价'
      },
      {
        name: 'realPriceShow',
        lable: '金额'
      },
      {
        name: 'number',
        lable: '数量'
      },
      {
        name: 'doctorId',
        lable: '医生'
      },
      {
        name: 'nurseId',
        lable: '护士'
      },
      {
        name: 'consultantId',
        lable: '咨询师'
      },
    ]
    // 项目
    const addProjectList = ref<any[]>([])
    const getLeftData = (index: number) => {
      return (data: MockType[]) => {
        addProjectList.value[index].toothBit.leftTop = data
      }
    }
    const getRightData = (index:number) => {
      return (data: MockType[]) => {
        addProjectList.value[index].toothBit.rightTop = data
      }
    }

    const getLeftBottomData = (index:number) => {
      return (data: MockType[]) => {
        addProjectList.value[index].toothBit.leftBottom = data
      }
    }

    const getRightBottomData = (index: number) => {
      return (data: MockType[]) => {
        addProjectList.value[index].toothBit.rightBottom = data
      }
    }

    // 重新获取账户余额
    const getCustomerAccountInfo = async(id:any) => {
      let res:any = await getCustomerAccountApi({}, id);
      if(res.code !== 0) return ElMessage.error(res.msg || '获取信息失败')

      let num = res.data.giftsOfGoldShow || 0;
      let balance = res.data.balanceShow || 0;
      window.localStorage.setItem('balanceShow', balance)
      window.localStorage.setItem('giftsOfGoldShow', num)

      accountBalance.value = balance;
      giftsOfGoldShow.value = num;

    }

     // 订单原价 
    const orderDetailSumMoneyShow = ref('')
    // 实际应付款（折后价）
    const originalPriceShow = ref(0)
    
    // 总欠费
    const totalArrears = computed(() => {
      let total = 0
      list.arrearsData.forEach((item: any) => {
        // 欠费 = 应收 - 实收
        total += item.arrears
      })
      return total
    })
    // （总账单的）实付金额
    const paid = computed(() => {
      let money = 0
      list.payment.forEach(item => {
        money += Number(item.moneyShow)
      })
      return money
    })

     // 侦听收欠费
    const paidArrearageList = computed(() => {
      let money = 0
      list.payMoneys.forEach(item => {
        item.details.map(j => {
          money += Number(j.moneyShow)
        })
        
      })

      return money
    })

    // （该项目的）实付金额
    const paidInAmount = computed(() => {
      let money = 0
      // （总账单的）实付金额 =  实际应付款
      if(paid.value === originalPriceShow.value) {
        money = paid.value
      }
      // （总账单的）实付金额 < 实际应付款
      if(paid.value <= originalPriceShow.value) {
        money = paid.value
      } else {
        // （总账单的）实付金额 > 实际应付款
        // 钱够了 
        money = originalPriceShow.value
      }


      
      return money
    })
    // 实付金额输入
    const paidInAMountInput = ref(0)
    // 余下的钱
    const restMoney = ref(0)
    // 所有欠费 =  应付金额 + 历史欠费
    const allArrears = computed(() => {
      return originalPriceShow.value + totalArrears.value
    })
    let allArrearsCopy = ref(0)
    
    watch(paid, (newP, prevP) => {
      if(arrearsTitle.value === '收费') {
        if(newP <= originalPriceShow.value) {
          paidInAMountInput.value = newP
          list.arrearsData.forEach((i:any) => i.paymentAmount = '')
        } else {
          // 这里是大于 项目实付金额
          paidInAMountInput.value = originalPriceShow.value;
          // 余下的钱 = 实付总额 - 实付金额（项目）
          restMoney.value = newP - originalPriceShow.value;

          for(let i = 0; i < list.arrearsData.length; i++) {
            // let restM = restMoney.value;
            if(restMoney.value - list.arrearsData[i].arrears >= 0) {
              // 说明 还有钱
              restMoney.value = restMoney.value - list.arrearsData[i].arrears
              
              // 
              if(restMoney.value >= 0) {
                list.arrearsData[i].paymentAmount = list.arrearsData[i].arrears
                
              } else {
                list.arrearsData[i].paymentAmount = restMoney.value
              }
              
            } else if (restMoney.value - list.arrearsData[i].arrears === 0) {
              list.arrearsData[i].paymentAmount = restMoney.value
              return false
            } else {
              // 钱不够
              list.arrearsData[i].paymentAmount = restMoney.value
              return false
            }
          }

        }
      }

      if(arrearsTitle.value === '收欠费') {
        
        
      }

      if(newP > allArrears.value) {
        ElMessage.warning('注意：您输入的实付金额, 已经超出欠费金额！')
      }


    } )


    // 验证输入框金额不大于实付金额 （提示）
    const handleVolidateFn = () => {
      let total = paid.value;
      let paidIn = originalPriceShow.value
      let result = 0;
      list.arrearsData.forEach((i: any) => {
        if(i.paymentAmount) {
          result += Number(i.paymentAmount)
        }
      })
      if((result + paidIn) > total) {
        ElMessage.error('请注意：您输入的金额大于实付总额')
        return false
      }
    }
    // 欠费历史输入实付
    const handleChangeInputVal = (val: string, data: any) => {
      let arrears = data.arrears || 0;
      let res = Number(val)
      
      // res > arrears ? ElMessage.error('请注意：您输入的金额大于欠费总额') : null;
      
    }

    const handleChangeValue = () => {
      handleVolidateFn()
    }

        // 医生下拉数据
    const optionsDoctors = ref([] as Doctors[])
    const optionsNurse = ref([] as Doctors[])
    const secondaryUserOptions = ref([] as Doctors[])
    const getDoctorAndNurse = async() => {
      // 获取医生

      let res:any = await getDoctorListAllAPi({})
      if(res.code !== 0) return ElMessage.error(res.msg || '获取信息失败')
      optionsDoctors.value = res.data

      // 获取护士
      let res1:any = await getNurseListAllAPi({})
      if(res1.code !== 0) return ElMessage.error(res1.msg || '获取信息失败')
      optionsNurse.value = res1.data

      // 获取咨询师
      let res2:any = await getConsultListAllAPi({})
      if(res2.code !== 0) return ElMessage.error(res2.msg || '获取信息失败')
      secondaryUserOptions.value = res2.data
    }
    // 支付方式
    const paymentOptions = ref([] as OptionDisable[])
    const disabledOption = (arr: Details[]) => {
      let newArr = arr.map(i => i.payType)
      paymentOptions.value.forEach((i, index) => {
        if(i.id === newArr[index]) {
          i.disabled = true
        }
      })
    }
    const addPayment = () => {
      disabledOption(list.payment)
      let res = list.payment.every(i => i.payType)
      if(res) {
        list.payment.push({
          isAdd: false,
          payType: '',
          moneyShow: '',
        })
      } else {
        ElMessage.warning('请选择支付方式')
      }
      
    }
    const delPayment = (index: number) => {
      let payType = list.payment[index].payType
      let refreshDisable = paymentOptions.value.find(i => i.id === payType)
      if(refreshDisable) {
        refreshDisable.disabled = false
      }
      list.payment.splice(index, 1)
    }
    const addPaymentItemList = (item: Details[]) => {
      console.log(item, '添加一项')
      disabledOption(item)
      let res = item.every(i => i.payType)
      if(res) {
        item.push({
          isAdd: false, // 是否显示添加
          payType: '', // 支付方式
          moneyShow: '' // 实付金额
        })
      } else {
        ElMessage.warning('请选择支付方式')
      }
      
    }
    const delPaymentItemList = (item: Details[], index:number ) => {
      console.log(index, '删除的索引')
      let payType = item[index].payType
      let refreshDisable = paymentOptions.value.find(i => i.id === payType)
      if(refreshDisable) {
        refreshDisable.disabled = false
      }
      item.splice(index, 1)
    }

    // 获取患者欠费订单
    const getArrCustomerDebtOrder = (ID: number) => {
      console.log(ID, "欠费")
      list.loading = true
      list.arrearsData = []
      request.sendRequest({
        address: `pay/order/getCustomerDebtOrder/${ID}`,
        params: {},
        success: (resp: RespData) => {
          if(resp.code !== 0) return ElMessage.error(resp.msg)
          list.arrearsData = resp.data;
          list.arrearsData.forEach((item: any) => {
            item.payment = [
                {
                  isAdd: true, // 是否显示添加
                  payType: '', // 支付方式
                  moneyShow: '' // 实付金额
                }
            ]
          })

          list.loading = false
        },
        fail: (resp: RespData) => {
          if(resp.code !== 0) return ElMessage.error(resp.msg)
          
        },
        method: "GET",
      })
    }
    const getPayMent = () => {
      request.sendRequest({
        address: 'pay/order/getCustomerType',
        params: {},
        success: (resp: RespData) => {
          if(resp.code !== 0) return ElMessage.error(resp.msg)
          paymentOptions.value = resp.data
        },
        fail: (resp: RespData) => {
          if(resp.code !== 0) return ElMessage.error(resp.msg)
          
        },
        method: "GET",
      })
    }

    const handleSelectionChange = (data: any) => {
      let arr = <PayMoneys[]>[]
      data.forEach((item: any) => {
        arr.push({
          orderId: item.id,
          details: item.payment
        })
      })
      
      list.payMoneys.push(...arr)
    }
    const newOrderId = ref(OrderID)

     // 新建账单保存(下单未付款)
    const saveOrder = async() => {
      if(addProjectList.value.length <= 0) {
        ElMessage.warning('您还未选择项目')
        return false
      } else {

        type OrderParams = {
          id?: number | null,
          customerId: number | string,
          details: any[],
          createTime: string,
          originalPriceShow: number
        }
        let params:OrderParams = {
          customerId: Number(ID),
          details: addProjectList.value,
          createTime: createTime.value,
          originalPriceShow: originalPriceShow.value
        }

        if(newOrderId.value) {
          params.id = newOrderId.value
        }

        // list.payMoneys = []
        let result:any = await usePromiseRequest('pay/order/completeOrder', params, 'POST')
        if(result.code == 0) {
          list.payMoneys.push({
              orderId: result.data.id,
              details: list.payment
            })
        }
        
      }
      

    }

    // 新增创建时间
    const createTime = ref('')
    const getOrderDetails = async(id: number) => {
      let result:any = await getOrderInfoAndDetailApi({}, id)
      if(result.data != null) {
        let order = result.data.details
        order.forEach((i: { toothBit: string }) => {
          i.toothBit = JSON.parse(i.toothBit)
        })
        createTime.value = result.data.createTime
        addProjectList.value = order
        orderDetailSumMoneyShow.value = result.data.orderDetailSumMoneyShow
        originalPriceShow.value = result.data.originalPriceShow

        setPamentMoney(originalPriceShow.value)
      }
    }

    // 存放收费打印数据
    const printList = ref<any[]>([])
    watch(() => printList.value, async(newV) => {
      await nextTick()
      printJS({
          printable: 'print-js',
          type: 'html',
          scanStyles: false,
          css: 'public/print.css'
        })
    })

    // 收费接口
    const handleArrears = () => {
      for(let i = 0; i < list.payMoneys.length; i++) {
          for(let j = i + 1; j < list.payMoneys.length; j++) {
            if(list.payMoneys[i].orderId == (list.payMoneys[j] && list.payMoneys[j].orderId)) {
              list.payMoneys.splice(j, 1);
              j--;
            }
          }
        }
      function tips(item: any) {
          return item.payType
        }

        let isPayType = list.payment.every(tips)
        if(!isPayType) {
          ElMessage.warning('请选择支付方式')
          return false
        }
        let params =  {
          customerId: ID,
          payTime: list.payTime,
          remark: list.remark,
          payMoneys: list.payMoneys
        }
        request.sendRequest({
            address: 'pay/order/payOrder',
            params,
            success: (resp: RespData) => {
              if(resp.code !== 0) return ElMessage.error(resp.msg)
              ElMessage.success('收费' + resp.msg)
              printList.value = resp.data || []
              list.payMoneys = []
              list.payment = [
                {
                  isAdd: true, // 是否显示添加
                  payType: '', // 支付方式
                  moneyShow: '' // 实付金额
                }
              ]
              list.remark =''
              
              ctx.emit('refeshList')

            },
            fail: (resp: RespData) => {
              if(resp.code !== 0) return ElMessage.error(resp.msg)
              
            },
            method: "POST",
          })
    }
    return {
      ...toRefs(list),
      arrearsTitle,
      male,
      female,
      MockColumns,
      addProjectList,
      getLeftData,
      getRightData,
      getLeftBottomData,
      getRightBottomData,
      getName,

      orderDetailSumMoneyShow,
      originalPriceShow,
      accountBalance,
      giftsOfGoldShow,
      totalArrears,

      paid,
      paidArrearageList,

      paidInAmount,
      paidInAMountInput,
      restMoney,
      allArrears,
      allArrearsCopy,
      handleVolidateFn,
      handleChangeInputVal,
      handleChangeValue,

        // 打印数据
      printList,

      optionsDoctors,
      optionsNurse,
      secondaryUserOptions,
      getDoctorAndNurse,
      paymentOptions,
      addPayment,
      delPayment,
      getArrCustomerDebtOrder,
      getPayMent,
      handleSelectionChange,
      newOrderId,
      saveOrder,
      handleArrears,
      getOrderDetails,

      addPaymentItemList,
      delPaymentItemList,
    }
  }
})
</script>

<style lang="scss" scoped>
@import '@style/chargedialog';

.none { display:none;}
.btn-text {
  font-size: $fontSize-3;
  color: #606266;
}
</style>